package com.yunxi.core.util;

import org.apache.poi.ss.formula.functions.T;
import org.dozer.Mapper;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by xuruzi on 2019/5/31.
 */
public class DozerUtil {

    /**
     * list 2 list 映射
     * @param sourceList
     * @param targetObjectClass
     * @param <T>
     * @param <S>
     * @return
     */
    public static <T,S>List<T> mapList(Mapper dozerMapper,List<S> sourceList,Class<T> targetObjectClass){
        List<T> targetList = new ArrayList<T>();
        for(S s : sourceList){
            targetList.add(dozerMapper.map(s,targetObjectClass));
        }
        return targetList;
    }

}
